package pl.edu.agh.anomalyids.network;

import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import pl.edu.agh.anomalyids.network.header.Header;

public class Packet implements Serializable {
	
	private static final long serialVersionUID = 1L;

	public enum Protocol {
		TCP, UDP, ICMP, HTTP, IPv4
	}
	
	private Map<Protocol, Header> protocols = new HashMap<Protocol, Header>();
	private Date time;

	public Map<Protocol, Header> getProtocols() {
		return protocols;
	}
	
	public void addProtocol(Protocol protocol, Header header) {
		protocols.put(protocol, header);
	}
	
	public Date getTime() {
		return time;
	}
	
	public void setTime(Date time) {
		this.time = time;
	}
	
	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		
		builder.append("========= Packet =========\n");
		
		builder.append("Time: ");
		builder.append(getTime());
		builder.append("\n");
		
		for (Protocol protocol : protocols.keySet()) {
			builder.append(protocols.get(protocol).toString());
		}
		
		builder.append("======= End of Packet =======\n\n");
		
		return builder.toString();
	}
}
